<?php include("mainlist.php");?>
<table cellspacing="0" border="0" width="995">
	<tr>
		<td width="200" valign="top">					
			<?php
				include("menuleftcategory.php");
			?>
		</td>	
		<td width="795" valign="top">
			<?php
				$id=$_GET['id'];
			?>
			<form action="index.php?admin=productAdmin&do=formeditcategory&id=<?php echo $id;?>" method="post" enctype="multipart/form-data">
			<table cellspacing="0" border="0" width="790">
					<tr>
						
						<td width="790" class="title_manager_cate">Sửa danh mục</td>
					
					</tr>
				</table>
			<table class="reference" cellspacing="0" border="1" width="100%">
			<tr>
				<td colspan="2" align="center">
					<?php
						//$id=$_GET['id'];	
						$cateName = $_POST['cateName'];
						if(isset($_POST['submit'])){
							if($cateName==''){
								echo "<font color=\"red\">Bạn phải nhập vào tên danh mục sản phẩm.</font>";
							}else{
								$query="UPDATE categories SET cateName='$cateName' WHERE id=$id";
								mysql_query($query);
								echo "Nhóm danh mục sản phẩm đã được sửa thành công.";
								echo "<script>window.location='index.php?admin=productAdmin&do=listproduct'</script>";
							
							}
						}
						
					?>
				</td>
			</tr>
			<?php
				$query="SELECT * FROM categories WHERE id=$id";
				$result=mysql_query($query);
				while($row=mysql_fetch_array($result)){?>
					<tr>
						<td width="200"><b>Tên danh mục:</b></td>
						<td>
							<input type="text" name="cateName" size="40" value="<?php echo $row['cateName']?>" />
						</td>
					</tr>
					
			<?php
			}
			?>   	      	 
				   <tr>
						<td></td>
						<td>
							<input type="submit" name="submit" value="Sửa danh mục" />
							<input type="button" name="Cancel" value="Cancel" onclick="window.location = 'index.php?admin=productAdmin&do=listproduct' " /> 
						<td>
				   </tr>
				</table>
			</form>
		</td>
	</tr>	
</table>